//
//  JSQImageMarkLabel.m
//  Conversation
//
//  Created by C_HAO on 15/10/16.
//  Copyright © 2015年 CHAOO. All rights reserved.
//

#import "JSQImageMarkLabel.h"

@interface JSQImageMarkLabel ()

@property (nonatomic, assign) NSInteger total;
@property (nonatomic, assign) NSInteger page;

@end

@implementation JSQImageMarkLabel

- (instancetype)initWithFrame:(CGRect)frame withTotal:(NSInteger)total {
    self = [super initWithFrame:frame];
    if (self) {
        _total = total;

        self.backgroundColor = [UIColor colorWithWhite:0.000 alpha:0.360];
        self.font = [UIFont systemFontOfSize:15];
        self.textColor = [UIColor whiteColor];
        self.textAlignment = NSTextAlignmentCenter;
        self.layer.masksToBounds = YES;
        self.layer.cornerRadius = 5;
        self.layer.borderWidth = 1;
        self.layer.borderColor = [UIColor colorWithWhite:0.984 alpha:0.730].CGColor;
    }
    return self;
}

- (void)showPageNumber:(NSInteger)page {
    if (_page != page || !_page) {

        _page = page;

        [self setNeedsLayout];
    }
}

- (void)layoutSubviews {
    self.text = [NSString stringWithFormat:@"%@/%@", @(_page), @(_total)];

    [super layoutSubviews];
}

@end
